#!/bin/bash

PID=$1
TIME=${2:-10}
RATE=${3:-97}
FRAMES=${4:-6000}
DIR="/tmp"
echo perf record -p $PID -F $RATE --call-graph fp,60000 -o $DIR/out-$PID.data -- sleep $TIME
perf record -p $PID -F $RATE --call-graph fp,60000 -o $DIR/out-$PID.data -- sleep $TIME
perf script -i $DIR/out-$PID.data --max-stack=60000 > $DIR/out-$PID.perf
$FLAME_GRAPH_HOME/stackcollapse-perf.pl $DIR/out-$PID.perf > $DIR/out-$PID.stacks
